package equipement;

public class Armure extends Objet {
	
	private EArmure armure;
	private int pv;
	private int pvMax;
	private int absorption;
	private int absorptionMax;
	private boolean isMaitre;
	private String special;
	
	public Armure (EArmure armure){
		SetArmure(armure);
	}
	
	public void SetArmure (EArmure armure){
		this.armure = armure;
		this.special = null;
		this.isMaitre = false;
		
		switch(armure)
		{
		case Tunique :
			this.pvMax = 1;
			this.absorptionMax = 0;
			break;
		case ArmureDeCuir :
			this.pvMax = 60;
			this.absorptionMax = 3;
			break;
		case CoteDeMaille :
			this.pvMax = 120;
			this.absorptionMax = 6;
			break;
		case Harnois :
			this.pvMax = 200;
			this.absorptionMax = 10;
			break;
		case HarnoisDeMaitre :
			this.pvMax = 300;
			this.absorptionMax = 15;
			this.isMaitre = true;
			break;
		case CuirasseDeResistanceAuFeu :
			this.pvMax = 180;
			this.absorptionMax = 9;
			this.special = "absorption de feu de 10";
			this.isMaitre = true;
			break;
		}
		
		this.pv = this.pvMax;
		this.absorption = this.absorptionMax;
	}
	
	public int getPv() {
		return pv;
	}
	
	public EArmure getArmure() {
		return armure;
	}

	public void setPv(int pv) {
		this.pv = pv;
		
		int pvMaxNormal = this.pvMax;
		int absorptionMaxNormal = this.absorptionMax;
		
		if(isMaitre)
		{
			pvMaxNormal = (this.pvMax*2)/3;
			absorptionMaxNormal = (this.absorptionMax*2)/3;
		}
		

		if(pv<=(pvMaxNormal/4))
			this.absorption = absorptionMaxNormal/4;
		else if(pv<=(pvMaxNormal/2))
			this.absorption = absorptionMaxNormal/2;
		else if(pv<=((3*pvMaxNormal)/4))
			this.absorption = (absorptionMaxNormal*3)/4;
		else if(pv<=pvMaxNormal)
			this.absorption = absorptionMaxNormal;
		else
			this.absorption = this.absorptionMax;
		
	}

	public String toString(){
		String res = this.armure.toString() + " : PV [" + this.pv + "/" + this.pvMax + 
				"] - Absorption [" + this.absorption + "/" + this.absorptionMax + "]";
		
		if(this.special != null)
			res = res + " - Special [" + this.special + "]";
		
		return res;
	}
}
